package com.simplefaith.delisty.util;

import java.util.ArrayList;
import java.util.List;

import com.simplefaith.delisty.client.ClientInstance;

import android.app.Activity;

public class ActivityStackControlUtil {

	private static List<Activity> activityList = new ArrayList<Activity>();

	public static void remove(Activity activity) {

		activityList.remove(activity);

	}

	public static void add(Activity activity) {

		activityList.add(activity);

	}

	/**
	 * Quit Application
	 * 
	 * this function will handle connection interrupt
	 * */
	public static void finishProgram() {

		ClientInstance.getClient().DisConnect();

		for (Activity activity : activityList) {
			try {
				activity.finish();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

		android.os.Process.killProcess(android.os.Process.myPid());

	}
}